//
//  ZNMapCluster.h
//  BaiduCluster
//
//  Created by LiZNing on 14-4-2.
//  Copyright (c) 2014年 lzning. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BMapKit.h"
#import "ZNMapPointAnnotation.h"

@interface ZNMapCluster : NSObject
{
    CLLocationCoordinate2D _clusterCoordinate;
    ZNMapCluster *         _leftChild;
    ZNMapCluster *         _rightChild;
    BMKMapRect              _mapRect;
    ZNMapPointAnnotation * _annotation;
    NSString *             _clusterTitle;
    NSInteger              _depth;
}

@property (nonatomic) CLLocationCoordinate2D clusterCoordinate;
@property (nonatomic, readonly) NSString * title;
@property (nonatomic, readonly) NSString * subtitle;
@property (nonatomic, retain) ZNMapPointAnnotation * annotation;
@property (nonatomic, readonly) NSMutableArray * originalAnnotations;
@property (nonatomic, readonly) NSInteger depth;
@property (nonatomic, assign) BOOL showSubtitle;


- (id)initWithAnnotations:(NSArray *)annotations atDepth:(NSInteger)depth inMapRect:(BMKMapRect)mapRect gamma:(double)gamma clusterTitle:(NSString *)clusterTitle showSubtitle:(BOOL)showSubtitle;

+ (ZNMapCluster *)rootClusterForAnnotations:(NSArray *)annotations gamma:(double)gamma clusterTitle:(NSString *)clusterTitle showSubtitle:(BOOL)showSubtitle;

- (NSArray *)find:(NSInteger)N childrenInMapRect:(BMKMapRect)mapRect;

- (NSArray *)children;

- (BOOL)isAncestorOf:(ZNMapCluster *)mapCluster;

- (BOOL)isRootClusterForAnnotation:(id<BMKAnnotation>)annotation;

- (NSInteger)numberOfChildren;

- (NSArray *)namesOfChildren;

@end
